<?php 
// wymagane w layout
//echo $this->Section->main();
?>

<div class="content-homenpage">
	<?php echo $this->element('carousel',array('plugin' => 'store',
		'items'=>$this->Store->products(4,array('limit'=>12))
		,'group_id'=>4
		,'params'=>array('width'=>190,'height'=>190,'padding'=>10,'margin'=>10,'border'=>1)
		));?>	
	<div class="clr"></div>	
</div>	
		
<div class="clr"></div>
<div class="content-homenpage">
	<div id="left-column">
		<?php echo $this->element('left_column')?>		
	</div>
	
	<div class="right-store-column search-bg">
		<?php echo $this->element('search_more',array('plugin'=>'store'))?>
	</div>
	
	<div class="right-store-column">
		<div class="posts">
			<table class="blog">
				<?php foreach ($posts as $post): ?>
				<tr>
					<td>
					<table width="100%" cellpadding="10" cellspacing="0" class="post">
						<tr>
							<td><?php echo $this->Html->link('<h2>'.$post['Post']['name'].'</h2>', array('action' => 'view', $post['Post']['id']),array('escape'=>false)); ?>
								<span class="modified-date"><?php echo $post['Post']['modified']; ?></span>&nbsp;
							</td>
						</tr>
						<tr>
							<td class="content">
							<?php echo $this->Text->truncate(
								    $post['Post']['content'],
								    150,
								    array(
								        'ending' => '...',
								        'exact' => true,
								    	'html' => true
								    ));
							?>&nbsp;</td>
						</tr>
						<tr>
							<td>
								<table class="corners" bgcolor="#bbbbbb" cellpadding="4" width="100%" cellspacing="4">
									<tr>
										<td valign="middle" width="12%">
											<?php echo __('Comments:',true)?>
										</td>
										<td valign="middle" align="center" width="3%">
											<?php echo count($post['Comment'])?>
											
										</td>
										<td valign="middle" width="45%">&nbsp;</td>
										<td align="right" valign="middle" width="40%">
											<?php echo $this->Html->link(__('+ add comment',true), array('controller'=>'comments','action' => 'add', $post['Post']['id']),array('class'=>'button corners')); ?>
											&nbsp;&nbsp;
											<?php echo $this->Html->link(__('view post',true), array('controller'=>'posts','action' => 'view', $post['Post']['id']),array('class'=>'button corners')); ?>
										</td>								
									</tr>
								</table>
							</td>
						</tr>
					</table>
					</td>
				</tr>
				<?php endforeach; ?>
			</table>
			<div class="paging-content">
			<p>
				<?php
				echo $this->Paginator->counter(array(
				'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
				));
				?>	
			</p>
			
			<div class="paging">
				<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
			 	<?php echo $this->Paginator->numbers(array('separator'=>false));?>
			 	<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
			</div>
			</div>
		</div>
	</div>
</div>

<?php if($session->check('Auth.User.id')){?>
<?php echo $this->element('toolbar_actions_main',array('plugin'=>'blog','toolbar'=>'posts'))?>
<?php }?>	